$(function () {
    function Linear(t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    }
    var moveAn;

    var t = 0;
    var d = 100;

    $(document).mousemove(function (e) {
        cancelAnimationFrame(moveAn);
        t = 0;
        d = 100;
        var xxx = e.pageX - document.documentElement.offsetWidth / 2;
        var yyy = e.pageY - document.documentElement.offsetHeight / 2;
        // y = e.pageY;
        js();

        function js() {
            t++;
            dx = parseFloat($(".tran1").attr('x'));
            dy = parseFloat($(".tran1").attr('y'));

            dx = Linear(t, dx, xxx - dx, d);
            dy = Linear(t, dy, yyy - dy, d);

            $(".tran1").attr("x", dx);
            $(".tran1").attr("y", dy);

            $(".tran1").css("transform", "translate3d(" + dx / 20 + "px," + dy / 20 + "px,0px)")
            $(".tran2").css("transform", "translate3d(" + -(dx / 20) + "px," + -(dy / 20) + "px,0px)")



            if (t >= d) {
                cancelAnimationFrame(moveAn);
            } else {
                moveAn = requestAnimationFrame(js);
            }

        }
    });






});